
package it.bd.SetAllConnectionsOff.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.SeekBar;
import android.widget.TabHost;
import android.widget.TextView;

import it.bd.SetAllConnectionsOff.R;

/**
 * @author Mihai HARAS (Lohmar ASHAR) 2011
 */
public abstract class ATabActivity extends Activity {
    CheckBox cbWifiState;
    CheckBox cbGpsState;
    CheckBox cbBluetoothState;
    CheckBox cbNetworkState;
    CheckBox cbBrightness;
    SeekBar  sbScreenBrightness;
    TextView tvBrightness;

    /**
     * Attaches this activity to the tab host (creates an activity in the {@link TabHost})
     * 
     * @param tabHost
     * @param context
     */
    public void attachOnTabHost(TabHost tabHost) {
        Intent i = new Intent(getContext(), this.getClass());
        tabHost.addTab(tabHost.newTabSpec(getTabTag()).setIndicator(getIndicator()).setContent(i));
    }

    abstract Context getContext();

    /**
     * @return the "TabSpec indicator" (label) for the tab
     */
    abstract String getIndicator();

    /**
     * @return the "TabSpec tag" (id) for the tab
     */
    abstract String getTabTag();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.frame);
        cbWifiState = (CheckBox) findViewById(R.id.cbWifiState);
        cbGpsState = (CheckBox) findViewById(R.id.cbGpsState);
        cbBluetoothState = (CheckBox) findViewById(R.id.cbBluetoothState);
        cbNetworkState = (CheckBox) findViewById(R.id.cbNetworkState);
        cbBrightness = (CheckBox) findViewById(R.id.cbBrightness);
        
        sbScreenBrightness = (SeekBar) findViewById(R.id.sbScreenBrightness);
        tvBrightness = (TextView) findViewById(R.id.brightness);
        
        setupNetwork();
        setupGps();
        setupBluetooth();
        setupWifi();

        setupScreenBrightness();
    }

    abstract void setupBluetooth();

    abstract void setupGps();

    abstract void setupNetwork();

    abstract void setupScreenBrightness();

    abstract void setupWifi();

}
